package com.chenj.cloudserverside;

import com.chenj.grpc.lib.HelloReply;
import com.chenj.grpc.lib.HelloRequest;
import com.chenj.grpc.lib.SimpleGrpc;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

import java.util.Date;

/**
 * <p>
 * 类注释
 * </p>
 *
 * @since: 2022/8/13 18:15
 * @author: liyi
 */
@GrpcService
public class GrpcServerService extends SimpleGrpc.SimpleImplBase {

    @Override
    public void sayHello(HelloRequest request,
                         StreamObserver<HelloReply> responseObserver) {
        String resMsg = "Hello " + request.getName() + ", " + new Date();
        System.out.println("resMsg=" + resMsg);
        HelloReply reply = HelloReply.newBuilder().setMessage(resMsg).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}
